#include<stdio.h>
int main(){
	int n,m;
	scanf("%d",&n);
	for(m=1;m<=n;m++){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		if(a<1||a>100||b<1||b>100||c>100||c<1)
		printf("Impossible");
		int x;
		for(x=1000;x<9999;x++){
			if(x%a==0&&(x+1)%b==0&&(x+2) % c == 0)
			{printf("%d\n",x);
			break;
			}
			}
	if(x==9999)
	printf("Impossible\n"); 
	}
	return 0;
} 
